var userListParams = {
    page: {
        add: ["system/user/userAdd.html", "userAdd", "新增用户"],
        edit: ["system/user/userAdd.html", "userEdit", "编辑用户"]
    },
    model: {
        "user_name": {
            "comment": "用户名",
            "type": "varchar",
        }
        , "name": {
            "comment": "姓名"
        }
        , "state": {
            "comment": "状态",
            "type": "number",
            "item": {
                "0": "禁用",
                "1": "启用"
            }
        } , "sex": {
            "comment": "性别",
            "type": "number",
            "item": {
                "0": "保密",
                "1": "男",
                "2": "女"
            }
        }
        , "phone": {
            "comment": "电话"
        }, "birthday": {
            "comment": "出生日期",
            "type": "date"
        }, "create_time": {
            "comment": "创建时间",
            "type": "datetime"
        }
    },
    action:{
        findPage:"sysUser/selectPageUserVo"
    }
}
$(function () {
    $("#btnAdd").click(function () {
        globalParams.tabInnerChange(userListParams.page.add);
    });
    $("#btnAdvancedSearch").click(function () {
        requestUtilParams.createAdvancedQueryDialog(userListParams.model,"#userSearchDialog");

    });
    findPageData();
});
/**
 * @title:<h3>分页查询用户列表数据  <h3>
 * @author: Enzo
 * @date: 2018-10-22 13:35
 * @params
 * @return
 **/
function findPageData(cpage) {
    requestUtilParams.findPageData(userListParams.action.findPage,cpage,"#tableList","printPage",findPageData).done(function (res) {
        var list=res.data.list;
        var $tbody=$("#tableList tbody");
        for(var i=0;i<list.length;i++){
            var $tr=$("<tr></tr>");
        $tr.append('<td><input type="checkbox" class="inpDel"></td>');
            $tr.append('<td>'+list[i].user.account+'</td>');
            $tr.append('<td>'+baseUtilParams.strNullFilter(list[i].user.phone)+'</td>');
            $tr.append('<td>'+baseUtilParams.strNullFilter(list[i].user.name)+'</td>');
            //$tr.append('<td>'+baseUtilParams.strNullFilter(list[i].role_names)+'</td>');
            $tr.append('<td>'+baseUtilParams.strNullFilter(list[i].user.address)+'</td>');
            $tr.append('<td>'+baseUtilParams.simpDataForYYYMMDD(list[i].user.birthday)+'</td>');
            $tr.append('<td class="layui-form"><input type="checkbox" lay-skin="switch" checked></td>');
            var $btns=$("<td></td>");
            $btns.append('<a href="roleUpdate.html" class="layui-btn layui-btn-xs layui-btn-normal">编辑</a>')
            $btns.append('<a class="layui-btn layui-btn-danger layui-btn-xs">删除</a>');
            $tr.append($btns);
            $tbody.append($tr);
        }
        layui.use("form",function () {
           var form=layui.form;
            form.render();
        });

    })
}



